from messAround.model.baidu import BaiduTiebaModel, BaiduTopModel
import messAround.util.help as util


# 百度贴吧实时热点话题
class BaiduTiebaTopicPipeline(object):

    @staticmethod
    def process_item(item, spider):
        return util.make_write_data({
            'topic_id': int(item["topic_id"]),
            'title': item["title"],
            'full_title': item["full_title"],
            'link': item["link"],
            'info': item["info"],
            'cover': item["cover"],
            'discuss_num': int(item["discuss_num"]),
        }, item, BaiduTiebaModel)


# 百度热搜
class BaiduTopTopicPipeline(object):
    @staticmethod
    def process_item(item, spider):
        return util.make_write_data({
            'title': item["title"],
            'category': item["category"],
            'link': item["link"],
            'info': item["info"],
            'hot_index': item["hot_index"],
        }, item, BaiduTopModel)
